複数のtext fileを一つのJSON配列にまとめるscript
複数のtext fileを一つのJSON配列にまとめるscript
code:js
(async () => {
const {join} = await import('/api/code/takker/複数のtext_fileを一つのJSON配列にまとめるscript/script.js');
const {downloadObject} = await import('/api/code/takker/web_browserから任意のデータをdownloadするscript/script.js');
const texts = await join();
downloadObject(texts);
})();
用途
OCRしたバラバラのファイルを一つにまとめる
dependencies
code:script.js
import {getLocalFiles} from '../簡単にfileをbrowserに取り込むscript/script.js';
import {BlobToURI} from '../BlobをData_URIに変換する/script.js';
export async function join({compareFunction, convertName, verbose} = {}) {
compareFunction = compareFunction ?? new Intl.Collator().compare;
convertName = convertName ?? (title => title);
const files = await getLocalFiles({accept: '.txt', multiple: true});
.sort((a, b) => compareFunction(a.name, b.name))
.map(async file => await file.text())
);
console.log(data);
return data;
}